<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>元旦活动</title>
    <script type="text/javascript" src="./js/tool.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <link rel="stylesheet" href="./css/normalize.min.css">
    <link rel="stylesheet" href="./css/animate.min.css">
    <link rel="stylesheet" href="./css/common.min.css">
    <link rel="stylesheet" href="./css/loading.css">
    <link rel="stylesheet" href="./css/lovestyle.min.css">
    <style media="screen">
        .loading {}
    </style>
</head>

<body class="animated ">
    <div class="loading">
        <div class="cube cube1"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube2"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube3"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube4"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube5"><img src="./images/heart.png" alt="" /></div>
        <div class="loading-info">
            <p>加载中...</p>
        </div>
    </div>

    <header>
        <a href="#" class="logo"></a>
    </header>
    <article>
        <div class="f28 lemiao" id="heartData">
            <p><span class="lovetag"></span></p>
            <p><span class="lovetag"></span><span><img id="uImg"></img></span><span class="lovetag"></span><i class="_2018word f36 heilizhi">2018，<b id="uName"></b>最爱...</i>
            </p>
            <p><span class="lovetag"></span><span class="lovetag"></span></p>
        </div>
    </article>
    <footer>
        <p class="t-c f30 lemiao">沃妹帮你寻找2018年的自己，</p>
        <p class="t-c f30 lemiao">参与游戏还有机会获得暖心好礼哦~</p>
        <a href="javascript:void(0);" id='gotoGameBtn'></a>
    </footer>
    <div class="follow  animated panel">
        <div class="ruler_contianer panel_contianer">
            <!-- <a href="javascript:void(0);" id="followBtn"></a> -->
            <p class="t-c m-t-30 lemiao"><i class="my_heart"></i>啊哦，你还没有关注哦~</p>
            <p class="t-c lemiao">扫一扫下方二维码关注“四川联通”即可参与游戏</p>
            <p class="t-c"> <a href="" id="imgCode">
                <img src="./images/wechat.png" alt="">
                </a>
            </p>
        </div>
    </div>
    <script src='./js/follow.js'></script>
    <script type="text/javascript" src="./js/openInWeChat.js"></script>
    <script>
        //强制在微信浏览器打开
        // WechatUseAgent();
    </script>
    <script>
        //禁止拖动
        preventMove();
    </script>
    <script>
        //监听请求全部获取成功
        var imgNum = [0];

        lisetnerAjax(imgNum, 'body');

        var app = {
            openId: GetRequest()['openid'],
            user: {},
            init: function() {
                // this.showWoLove();
                var context = this;
                this.gotoGame();
                this.closePanel();
                this.bindCheck();
                this.getUserRecord();
            },
            closePanel: function() {
                closeBar('#followBtn', '.follow');
            },
            gotoGame: function() {
                $('#gotoGameBtn').click(function() {
                    location.href = "./index.html";
                })
            },
            lovetagPanel: function(love) {
                var context = this;
                $.each($('.lovetag'), function(index, val) {
                    $(val).html(love[index].name);
                });
            },
            checkUserInfo: function() {
                var context = this;
                var html = '';
                if (context.user.love.length > 0) {
                    var love = context.user.love;
                    html =
                        `<p><span>${love[0].name}</span></p>
                        <p><span>${love[1].name}</span><span><img src='${context.user.imgUrl}'></img></span><span>${love[2].name}</span><i class="_2018word f36 heilizhi">2018，${context.user.name}最爱...</i>
                        </p>
                        <p><span>${love[3].name}</span><span>${love[4].name}</span></p>`
                }
                //console.log(html);
                $('#heartData').html(html);
            },
            getUserRecord: function() {
                //console.log('111');
                var context = this;

                $.ajax({
                    tyle: 'post',
                    url: "http://10.122.202.211:8080/HD-newyear/newyear/getUserRecord.action",
                    dataType: "jsonp",
                    jsonp: "callback",
                    data: {
                        openid: app['openId']
                    },
                    beforeSend: function() {
                        //判断openId传过来了没有
                        if (!Boolean(app['openId'])) {
                            alert('获取openId失败');
                        }
                    },
                    success: function(response) {
                        //console.log('11');
                        imgNum[0] = 1;
                        if (0 == response.code) {
                            //显示文字
                            if (Boolean(response.data)) {
                                $.each(response.data, function(index, val) {
                                    if (!val.prizetype) {
                                        context.user.love.push(val);
                                    }
                                })

                            }
                            var timer = setInterval(function() {
                                if (context.user.love.length == 5) {
                                    context.lovetagPanel(context.user.love);
                                    clearInterval(timer);
                                    timer = null;
                                }
                            }, 200);
                        }
                    },
                    error: function() {}
                });
            },
            bindCheck: function() {
                var context = this;
                context.user = judgeFocuse(app['openid']);
                var timer = setInterval(function() {
                    if (Boolean(context.user['name'])) {
                        //console.log(context.user.name);

                        $('#uImg').attr('src', context.user.imgUrl);
                        $('#uName').text(context.user.name);

                        clearInterval(timer);
                        timer = null;
                    }
                }, 200);

            }
        }
        app.init();
    </script>
</body>

</html>
